class RectObject
{
  Coordinate c1, c2;
  
  RectObject( float x1, float y1, float x2, float y2 )
  {
    c1 = new Coordinate( x1, y1 );
    c2 = new Coordinate( x2, y2 );
  }
  
  RectObject( int x1, int y1, int x2, int y2 )
  {
     this( (float)x1, (float)y1, (float)x2, (float)y2 );
  }
  
//----------------------------------------DRAW METHODS----------------------------------------------
  void draw()
  {
    if( isTargeting() )
      update(); 
  }
//---------------------------------------END DRAW METHODS------------------------------------------

//------------------------------------------ANIMATION METHODS----------------------------------------
  boolean isTargeting()
  {
    return c1.isTargeting() || c2.isTargeting() ;
  }
  
  void target( float x1, float y1, float x2, float y2 )
  {
    c1.target( x1, y1 );
    c2.target( x2, y2 );
  }
  
  void target( int x1, int y1, int x2, int y2 )
  {
    this.target( (float)x1, (float)y1, (float)x2, (float)y2 );
  }
  
  void targetX1(float newX1)
  {
    this.target( newX1, c1.y.target, c2.x.target, c2.y.target );
  }
  
  void targetY1(float newY1)
  {
    this.target( c1.x.target, newY1, c2.x.target, c2.y.target );
  }
  
  void targetX2(float newX2)
  {
    this.target( c1.x.target, c1.y.target, newX2, c2.y.target );
  }
  
  void targetY2(float newY2)
  {
    this.target( c1.x.target, c1.y.target, c2.x.target, newY2 );
  }
  
  void update()
  {
    if( c1.isTargeting() )
      c1.update();
    if( c2.isTargeting() )
      c2.update();
  }

//--------------------------------------END ANIMATION METHODS----------------------------------------

//----------------------------------------MOVEMENT METHODS-------------------------------------------
  void moveRight( float diff )
  {
    c1.moveRight(diff);
    c2.moveRight(diff);
  }
  
  void moveRight( int diff )
  {
    this.moveRight( (float)diff );
  }
  
  void moveLeft( float diff )
  {
    c1.moveLeft(diff);
    c2.moveLeft(diff);
  }
  
  void moveLeft( int diff )
  {
    this.moveLeft( (float)diff );
  }
  
  void moveUp( float diff )
  {
    c1.moveUp(diff);
    c2.moveUp(diff);
  }
  
  void moveUp( int diff )
  {
    this.moveUp( (float)diff );
  }
  
  void moveDown( float diff )
  {
    c1.moveDown(diff);
    c2.moveDown(diff);
  }
  
  void moveDown( int diff )
  {
    this.moveDown( (float)diff );
  }
  
  void moveHorizontally(float diff)
  {
    this.moveRight( diff );
  }
  
  void moveHorizontally(int diff)
  {
    this.moveRight( (float)diff );
  }
  
  void moveVertically(float diff)
  {
    this.moveDown( diff );
  }
  
  void moveVertically( int diff )
  {
    this.moveDown( (float) diff );
  }

  void moveDiagonally( float diffX, float diffY )
 {
   this.moveRight( diffX );
   this.moveDown( diffY );
 } 
 
 void moveDiagonally( int diffX, int diffY )
 {
   this.moveDiagonally((float) diffX, (float) diffY );
 }
 
 void moveCircular( )
 {
   //TO Do
 }
 
 void moveSquare( )
 {
   //To Do
 }
//----------------------------------------END MOVEMENT METHODS-------------------------------------

//--------------------------------------MODIFY SIZE OF OBJECT---------------------------------------  

//-----------------------INCREASE WIDTH------------------------
  //if modes == 0 , increase from center
  //if mode == 1, increase toward the right
  //if mode == 2 increase toward the left
  void increaseWidth( float diff, int mode )
  {
    if( mode == 0 )
      increaseWidthCentered( diff );
    else if( mode == 1 )
      increaseWidthToRight( diff );
    else if( mode == 2 )
      increaseWidthToLeft( diff );
  }
  
  void increaseWidth( int diff, int mode )
  {
    this.increaseWidth( (float) diff, mode );
  }
  
  void increaseWidthCentered( float diff )
  {
     c1.moveLeft( diff/2 );
     c2.moveRight( diff/2 );
  }
  
  void increaseWidthCentered( int diff )
  {
     this.increaseWidthCentered( (float)diff );
  }
  
  void increaseWidthToRight( float diff )
  {
    c2.moveRight( diff );
  }
  
  void increaseWidthToRight( int diff )
  {
     this.increaseWidthToRight( (float)diff );
  }
  
  void increaseWidthToLeft( float diff )
  {
    c1.moveLeft( diff );
  }
  
  void increaseWidthToLeft( int diff )
  {
     this.increaseWidthToLeft( (float)diff );
  }
//-------------------END INCREASE WIDTH------------------------

//--------------------DECREASE WIDTH--------------------------
  //if modes == 0 , increase from center
  //if mode == 1, increase toward the right
  //if mode == 2 increase toward the left
  void decreaseWidth( float diff, int mode )
  {
    if( mode == 0 )
      this.increaseWidthCentered( -1*diff );
    else if( mode == 1 )
      this.increaseWidthToRight( -1*diff );
    else if( mode == 2 )
      this.increaseWidthToLeft( -1*diff );
  }
  
  void decreaseWidth( int diff, int mode )
  {
    this.increaseWidth( (float) -1*diff, mode );
  }
  
  void decreaseWidthCentered( float diff )
  {
    this.increaseWidthCentered( -1*diff );
  }
  
  void decreaseWidthCentered( int diff )
  {
     this.increaseWidthCentered( (float)-1*diff );
  }
  
  void decreaseWidthToRight( float diff )
  {
    this.increaseWidthToRight( -1*diff );
  }
  
  void decreaseWidthToRight( int diff )
  {
     this.increaseWidthToRight( (float)-1*diff );
  }
  
  void decreaseWidthToLeft( float diff )
  {
    this.increaseWidthToLeft( -1*diff );
  }
  
  void decreaseWidthToLeft( int diff )
  {
     this.increaseWidthToLeft( (float)-1*diff );
  }
//------------------END DECREASE WIDTH------------------------

//-----------------------INCREASE HEIGHT-----------------------
  void increaseHeight( float diff )
  {
    this.increaseHeightCentered(diff);
  }
  
  void increaseHeight( int diff )
  {
    this.increaseHeight( (float) diff );
  }
  
  void increaseHeight( float diff, int mode )
  {
    if( mode == 0 )
      increaseHeightCentered( diff );
    else if( mode == 1 )
      increaseHeightDown( diff );
    else if( mode == 2 )
      increaseHeightUp( diff );
  }
  
  void increaseHeight( int diff, int mode )
  {
    this.increaseHeight( (float) diff, mode );
  }
  
  void increaseHeightCentered( float diff )
  {
     c1.moveUp( diff/2 );
     c2.moveDown( diff/2 );
  }
  
  void increaseHeightCentered( int diff )
  {
     this.increaseHeightCentered( (float)diff );
  }
  
  void increaseHeightDown( float diff )
  {
    c2.moveDown( diff );
  }
  
  void increaseHeightDown( int diff )
  {
     this.increaseHeightDown( (float)diff );
  }
  
  void increaseHeightUp( float diff )
  {
    c1.moveUp( diff );
  }
  
  void increaseHeightUp( int diff )
  {
    this.increaseHeightUp( (float)diff );
  }
//--------------------END INCREASE HEIGHT----------------------
 
//-------------------DECREASE HEIGHT---------------------------
 void decreaseHeight( float diff )
  {
    this.increaseHeightCentered(-1*diff);
  }
  
  void decreaseHeight( int diff )
  {
    this.increaseHeight( (float) -1*diff );
  }
  
  void decreaseHeight( float diff, int mode )
  {
    if( mode == 0 )
      increaseHeightCentered( -1*diff );
    else if( mode == 1 )
      increaseHeightDown( -1*diff );
    else if( mode == 2 )
      increaseHeightUp( -1*diff );
  }
  
  void decreaseHeight( int diff, int mode )
  {
    this.increaseHeight( (float) -1*diff, mode );
  }
  
  void decreaseHeightCentered( float diff )
  {
     c1.moveUp( -1*diff/2 );
     c2.moveDown( -1*diff/2 );
  }
  
  void decreaseHeightCentered( int diff )
  {
     this.increaseHeightCentered( (float)-1*diff );
  }
  
  void decreaseHeightDown( float diff )
  {
    c2.moveDown( -1*diff );
  }
  
  void decreaseHeightDown( int diff )
  {
     this.increaseHeightDown( (float)-1*diff );
  }
  
  void decreaseHeightUp( float diff )
  {
    c1.moveUp( -1*diff );
  }
  
  void decreaseHeightUp( int diff )
  {
     this.increaseHeightUp( (float)-1*diff );
  }

//----------------------END DECREASE HEIGHT-------------------
  void expandByPixels(float diff)
  {
    this.increaseWidthCentered(diff);
    this.increaseHeightCentered(diff);
  }
  
  void shrinkByPixels(float diff)
  {
    this.increaseWidthCentered(-1*diff);
    this.increaseHeightCentered(-1*diff);
  }
  
  void expandByPercentage(float perc)
  {
    float pix = c2.getY()-c1.getX();
    expandByPixels( perc*pix );
  }
  
  void shrinkByPercentage( float perc )
  {
    float pix = c2.getY()-c1.getX();
    shrinkByPixels( perc*pix );
  }
  
  void expandByMultiplier( int multiplier )
  {
    //TO DO
  }
 
 //--------------------------------------END MODIFY SIZE OF OBJECT---------------------------------------   

 //-------------------------------------------------GETTERS----------------------------------------------  
  float getX1()
  {
    return c1.getX();
  }
  
  float getX2()
  {
    return c2.getX();
  }
  
  float getY1()
  {
    return c1.getY();
  }
  
  float getY2()
  {
    return c2.getY();
  }
  
  float getActualX1()
  {
    return c1.getActualX();
  }
  
  float getActualX2()
  {
    return c2.getActualX();
  }
  
  float getActualY1()
  {
    return c1.getActualY();
  }
  
  float getActualY2()
  {
    return c2.getActualY();
  }
  
  
//----------------------------------------------END GETTERS-------------------------------------------------  
//--------------------------------------------------IS OVER METHODS------------------------------------------
  boolean mouseIsOver()
  {
    return mouseX >= c1.getX()- 5 &&  mouseX <= c2.getX() + 5 && mouseY >= c1.getY() - 5 && mouseY <= c2.getY() + 5;
  }
  
  boolean mouseIsOverPrecise()
  {
     return mouseX >= c1.getX() &&  mouseX <= c2.getX() && mouseY >= c1.getY() && mouseY <= c2.getY();
  }
  
  boolean xyIsOver(float x, float y)
  {
    return x >= c1.getX()- 5 &&  x <= c2.getX() + 5 && y >= c1.getY() - 5 && y <= c2.getY() + 5;
  }
  
  boolean xyIsOverPrecise(float x, float y)
  {
    return x >= c1.getX() &&  x <= c2.getX() && y >= c1.getY() && y <= c2.getY();
  }
  
//-----------------------------------------------END IS OVER METHODS------------------------------------------  

}//end class
